// (launch with OSC_send.ck)

// the patch
SndBuf buf[3];

buf[1] => dac;
buf[2] => dac;

// load the file
"./data/snare-hop.wav" => buf[1].read;
"./data/kick.wav" => buf[2].read;
// don't play yet
0 => buf[1].play; 
0 => buf[2].play; 

// create our OSC receiver
OscRecv recv;
// use port 9001
9001 => recv.port;
// start listening (launch thread)
recv.listen();

// create an address in the receiver, store in new variable
recv.event( "/drum1, i" ) @=> OscEvent oe;

// infinite event loop
while ( true )
{
    <<< "Running..." >>> ;
    // wait for event to arrive
    oe => now;

    // grab the next message from the queue. 
    while ( oe.nextMsg() != 0 )
    { 
        int i;
        // getFloat fetches the expected float (as indicated by "i")
        oe.getInt() => i => buf[i].play;
        
        // print
        <<< "got (via OSC):", buf[i].play() >>>;
        // set play pointer to beginning
        0 => buf[i].pos;
    }
}
